"""
# 比较
torch.eq(input, other, out) 按成员进行等式操作 相同返回true 返回的是一个 tensor
torch.equal(tensor1,tensor2) 如果tensor1和tensor2有相同的size和elements 则为true 返回的是一个boolean
torch.ge(input, other, out) input >= other
gorch.gt(input, other, out) input > other
torch.le(input, other, out) input <= other
gorch.lt(input, other, out) input < other
gorch.ne(input, other, out) input != other

# 排序
torch.sort(input, dim=None, descending=False, out=None) 对目标input进行排序
torch.topk(input, k, dim=None, largest=True, sorted=True, out=None) 沿着指定维度返回最多k个数值及其索引值
torch.kthvalue(input, k, dim=None, out=None) 沿着指定维度返回第k个最小值及其索引

# 判断有界性finite 无界性inf 是否有效数字nan
torch.isfinite(tensor)
torch.isinf(tensor)
torch.isnan(tensor)

"""
import torch

# a = torch.rand(2, 3)
# b = torch.rand(2, 3)
# print(a)
# print(b)
# print("==============================================")
# print(torch.eq(a, b))
# print(torch.equal(a, b))
# print(torch.ge(a, b))
# print(torch.gt(a, b))
# print(torch.le(a, b))
# print(torch.lt(a, b))
# print(torch.ne(a, b))

# a = torch.tensor([[1, 4, 2, 3, 4, 5], [2, 3, 1, 3, 4, 8]])
# print(torch.sort(a, descending=False))  # 返回索引
# print(torch.sort(a, descending=True))  # 返回索引
# print(torch.sort(a, descending=True, dim=0))  # 返回索引

# topk
# a = torch.tensor([[2, 4, 3, 1, 5], [2, 3, 5, 1, 4]])
# print(a.shape)
# print(torch.topk(a, k=1, dim=0))
# print(torch.kthvalue(a, k=2, dim=0))

a = torch.rand(2, 3)
print(a)
print(torch.isfinite(a))
print(torch.isfinite(a/0))
print(torch.isinf(a/0))
print(torch.isnan(a))


